import MyTable from '@/components/MyTable';
import AgentEdit from '@/pages/Act/components/editAgent';
import { findByPageList } from '@/services/goods';

const cloneTbale = () => {
  const columns = [
    {
      title: '自动编号',
      dataIndex: 'id',
      key: 'id',
      search: false,
      hideInTable: true,
    },
    {
      title: '图片',
      dataIndex: 'image',
      key: 'image',
      valueType: 'image',
    },
    {
      title: '名称',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: '维语名称',
      dataIndex: 'nameUg',
      key: 'nameUg',
      search: false,
    },
    {
      title: '数量',
      dataIndex: 'quantity',
      key: 'quantity',
      valueType: 'number',
    },
    {
      title: '库存数量',
      dataIndex: 'inventory',
      key: 'inventory',
      valueType: 'digit',
    },
    {
      title: '发布时间',
      dataIndex: 'publishTime',
      key: 'publishTime',
      valueType: 'datetime',
    },

    {
      title: '操作',
      width: '164px',
      key: 'option',
      valueType: 'option',
      render: (_: any, row: API.Agent, index: number, action: any) => [
        // eslint-disable-next-line react/jsx-key
        <a href={`/goods/edit/${row.id}`}>编辑</a>,
      ],
    },
  ];

  const toolbar = () => [<AgentEdit text={'新增'} isCard={true} />];
  // @ts-ignore
  return (
    <MyTable toolbar={toolbar} columns={columns} request={findByPageList} />
  );
};

export default cloneTbale;
